
#import "HLHomeTableViewController.h"
#import "HeFocus.h"
#import "HLHomeCell.h"
#import "HomeViewModel.h"
#import "headViewCollectionViewController.h"



@interface HLHomeTableViewController ()

@property (nonatomic, strong) NSArray *focusArr;

@property (nonatomic, strong) UIView *headView;



@end

@implementation HLHomeTableViewController

- (UIView *)headView {

    if (!_headView) {
        _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT/ 4)];
    }
    return _headView;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    

    [self setupUI];
}

/*
 http://115.28.86.228/travel_vision/trave_min/upload/day_150805/201508051806498292.jpg
 http://115.28.86.228/travel_vision/trave_min/upload/day_150806/201508060931403698.jpg
 http://115.28.86.228/travel_vision/trave_min/upload/day_150806/201508060928446782.jpg
 
 NSArray *arr = @[@"http://115.28.86.228/travel_vision/trave_min/upload/day_150805/201508051806498292.jpg",
 @"http://115.28.86.228/travel_vision/trave_min/upload/day_150806/201508060931403698.jpg",
 @"http://115.28.86.228/travel_vision/trave_min/upload/day_150806/201508060928446782.jpg"
 ];
 */

- (void)setupUI {
    
    self.focusArr = [HomeViewModel sharedHomeViewModel].heFocus;
    

    
    [self.tableView registerClass:[HLHomeCell class]forCellReuseIdentifier:ID];
    
    
//    headViewCollectionViewController *vc = [[headViewCollectionViewController alloc] init];
//    
//    [self addChildViewController:vc];
//    
//
////    self.headView.backgroundColor = [UIColor blueColor];
//    
//    
//    [self.headView addSubview:vc.view];
//    
//    [vc.view mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.mas_equalTo(self.headView);
//    }];
    
    
    NSString *str = [NSString stringWithFormat:@"sss,%@",STR];
    
    NSLog(@"%@",str);
    NSArray *arr = @[@"http://115.28.86.228/travel_vision/trave_min/upload/day_150805/201508051806498292.jpg",
                     @"http://115.28.86.228/travel_vision/trave_min/upload/day_150806/201508060931403698.jpg",
                     @"http://115.28.86.228/travel_vision/trave_min/upload/day_150806/201508060928446782.jpg"
                     ];
    
    
    NSMutableArray *url = [NSMutableArray array];
    for (NSString *str in arr) {
        NSURL * imageUrl = [NSURL URLWithString:str];
        [url addObject:imageUrl];
        
    }
    
    headViewCollectionViewController *vc = [[headViewCollectionViewController alloc] initWithframe:self.headView.frame images:url placeholderImage:[UIImage imageNamed:@"a50f4bfbfbedab643739c545f436afc378311eef"]];
    
    [self addChildViewController:vc];
    
    [self.headView addSubview:vc.view];
    
//    [vc.view mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.edges.mas_equalTo(self.headView);
//            }];
//
    self.tableView.tableHeaderView = self.headView;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HLHomeCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    cell.textLabel.text = @"hha";
    
    

    


    
    return cell;
}



@end
